<%@ include file="/WEB-INF/views/jsp/include/include.jsp"%>
<html>
<head>
<title>Hand In Hand</title>
<%@ include file="/WEB-INF/views/jsp/include/head.jsp"%>
</head>
<body>
	<%@ include file="/WEB-INF/views/jsp/include/header.jsp"%>
	<%@ include file="/WEB-INF/views/jsp/include/navigator.jsp"%>
	<%@ include file="/WEB-INF/views/jsp/include/errors.jsp"%>

	<div class="container-fluid">
		<form:form id="eventViewForm" modelAttribute="eventViewForm"
			method="post" action="../events/${eventViewForm.event.id}/post">
			<c:if
				test="${eventViewForm.event.community.privacy == 'PUBLIC' || eventViewForm.communityMember.user != null}">
				<div align="center" class="row">
					<div class="btn-group" role="group" aria-label="...">
						<c:if test="${eventViewForm.communityMember.user != null }">
							<button class="btn btn-default" type="button"
								onclick="location.href='<spring:url value="/communities/${eventViewForm.event.community.id}/newEvent"></spring:url>'">
								Create Event</button>
						</c:if>
						<button class="btn btn-default" type="button"
							onclick="location.href='<spring:url value="/communities/${eventViewForm.event.community.id}/events"></spring:url>'">
							Events of Community</button>
					</div>
					&nbsp;&nbsp;&nbsp;&nbsp;
					<div class="btn-group" role="group" aria-label="...">
						<c:if test="${eventViewForm.communityMember.user != null }">
							<button class="btn btn-default" type="button"
								onclick="location.href='<spring:url value="/communities/${eventViewForm.event.community.id}/newRequest"></spring:url>'">
								Create Request</button>
						</c:if>
						<button class="btn btn-default" type="button"
							onclick="location.href='<spring:url value="/communities/${eventViewForm.event.community.id}/requests"></spring:url>'">
							Requests of Community</button>
					</div>
					&nbsp;&nbsp;&nbsp;&nbsp;
					<div class="btn-group" role="group" aria-label="...">
						<c:if test="${eventViewForm.communityMember.user != null }">
							<button class="btn btn-default" type="button"
								onclick="location.href='<spring:url value="/communities/${eventViewForm.event.community.id}/newOffer"></spring:url>'">
								Create Offer</button>
						</c:if>
						<button class="btn btn-default" type="button"
							onclick="location.href='<spring:url value="/communities/${eventViewForm.event.community.id}/offers"></spring:url>'">
							Offers of Community</button>
					</div>
					<hr>
				</div>
			</c:if>

			<!--  Left Column for Community Name and Info -->
			<div style="height: 100% !important; word-break: break-word;"
				class="col-xs-3">
				<div
					style="border: 1px solid #b78f41 !important; border-radius: 10px;"
					class="col-xs-12">
					<img class="col-xs-10 col-xs-offset-1" style="margin-top: 5px;"
						src=<c:url value="/resources/images/community-icon.png"/>
						class="img-rounded"> <strong style="font-size: 16pt;">
						<c:out value="${eventViewForm.event.community.name}"></c:out>
					</strong><br>
					<button style="margin-top: 5px; margin-bottom: 5px;"
						class="btn btn-primary col-xs-12" type="button"
						onclick="location.href='<spring:url value="/communities/${eventViewForm.event.community.id}"></spring:url>'">
						Community Wall</button>
					<c:if test="${eventViewForm.moderatedEvent != null }">
						<button style="margin-top: 5px; margin-bottom: 5px;"
							class="btn btn-primary col-xs-12" type="button"
							onclick="location.href='<spring:url value="/communities/${eventViewForm.event.community.id}/events/${eventViewForm.event.id}/editEvent"></spring:url>'">
							Edit Event</button>
					</c:if>

				</div>
			</div>

			<div id="center" class="col-xs-6">

				<div id="eventWall">
					<!-- Post Submit -->
					<c:if
						test="${eventViewForm.event.community.privacy == 'PUBLIC' || eventViewForm.communityMember.user != null}">
						<div align="center"
							style="border: 1px solid #b78f41 !important; display: inline; border-radius: 10px; padding-bottom: 10px; padding-top: 10px;"
							class="col-xs-12">
							<label>Event Creator : </label>
							<c:out
								value="${eventViewForm.event.creator.name} ${eventViewForm.event.creator.surname}"></c:out>
							<br> <label>Name : </label>
							<c:out value="${eventViewForm.event.name}"></c:out>
							<br> <label>Starting Time : </label>
							<c:out value="${eventViewForm.event.startingTime}"></c:out>
							<br> <label>Ending Time : </label>
							<c:out value="${eventViewForm.event.endingTime}"></c:out>
							<br> <label>Location : </label>
							<c:out value="${eventViewForm.event.location}"></c:out>
							<br> <label>Information : </label>
							<c:out value="${eventViewForm.event.description}"></c:out>
							<br> <br>

							<c:if test="${eventViewForm.eventAttender.user == null}">
								<button class="btn btn-primary" type="button"
									onclick="location.href='<spring:url value="/communities/${eventViewForm.event.community.id}/events/${eventViewForm.event.id}/attendEvent"></spring:url>'">Attend
									this event</button>
							</c:if>

							<c:if test="${eventViewForm.eventAttender.user != null}">
								<c:if
									test="${eventViewForm.eventAttender.user.id != eventViewForm.event.creator.id}">
									<label>You are attending to this event</label>
									<button class="btn btn-primary" type="button"
										onclick="location.href='<spring:url value="/communities/${eventViewForm.event.community.id}/events/${eventViewForm.event.id}/unattendEvent"></spring:url>'">Do
										not attend</button>
								</c:if>
							</c:if>
						</div>
					</c:if>
					<br>
					<c:if test="${eventViewForm.communityMember.user != null}">
						<div align="center"
							style="border: 1px solid #b78f41 !important; display: inline; border-radius: 10px; padding-bottom: 10px; padding-top: 10px;"
							class="col-xs-12">
							<table style="width: 74%;">
								<tr>
									<td style="width: 90%;"><form:textarea
											style="width:100%; height:54px; resize:none;" path="post" />
									</td>
									<td>
										<button class="btn btn-primary" style="height: 54px;"
											type="submit">Post</button>
									</td>
								</tr>
							</table>
						</div>
					</c:if>
					<!-- Post View -->
					<c:if
						test="${eventViewForm.event.community.privacy == 'PUBLIC' || eventViewForm.communityMember.user != null}">
						<c:if test="${not empty eventViewForm.wallElements }">
							<div
								style="border: 1px solid #b78f41 !important; border-radius: 10px; padding-bottom: 10px; padding-top: 10px;"
								class="col-xs-12">
								<c:forEach var="element" items="${eventViewForm.wallElements}">
									<div
										style="border: 1px solid #898787 !important; border-radius: 10px; margin-top: 4px; margin-bottom: 4px; padding-bottom: 3px; padding-top: 3px;"
										class="col-xs-12">


										<img style="margin-top: 5px;" class="col-xs-2"
											src=<c:url value="/resources/images/maleicon.jpg"/>> <span>
											<a> ${element.user.name } ${element.user.surname }</a> 's
											post
										</span> <br> ${element.context}
									</div>
								</c:forEach>
							</div>
						</c:if>
					</c:if>
				</div>
				<!-- 				end of wall -->

			</div>
			<!-- 			end of center -->
<div class="col-xs-3">
			<!--  RECOMMENDATION	 -->
<div
					style="border: 1px solid #b78f41 !important; border-radius: 10px; margin-left: 3px; margin-right: 3px; padding-bottom: 10px; padding-top: 10px;"
					class="col-xs-8">
					<strong>RECOMMENDATIONS</strong>
			<c:forEach var="eventrecom"
				items="${eventViewForm.eventListofRecommendation}">
				<div
					style="overflow: hidden; border: 1px solid #898787 !important; border-radius: 10px; margin-top: 4px; margin-bottom: 4px; margin-left: 2px; margin-right: 2px; padding-bottom: 3px; padding-top: 3px;">

					<div
						style="padding-top: 6px; padding-bottom: 6px; padding-left: 4px; padding-right: 4px;">
						<a class="list-group-item-warning"
							href="<spring:url value='/communities/${eventrecom.community.id}/events/${eventrecom.id}'></spring:url>">
						
							<strong style="font-size: 0.9em; overflow-wrap: break-word;">${eventrecom.name}</strong>
						</a><br><span style="font-size: 0.7em; color: gray;overflow-wrap: break-word;">At: ${eventrecom.location}</span> <br> 
						<span
							style="font-size: 0.8em; font-style: oblique; height: 30px; overflow-wrap: break-word;">${eventrecom.description}</span>

					</div>
				</div>
			</c:forEach>

</div>

		</form:form>
	</div>
	</div>

	<%@ include file="/WEB-INF/views/jsp/include/footer.jsp"%>

</body>
</html>